<?php

			$nuolaida = 0;
			$nuolaidos_pvm = 0;
			$nuolaida_be_pvm = 0;

			$nestnuol_q = str_replace("<dok_nr>", addslashes_mssql($dok_nr), $nestnuol_q);
			$nuol = $db_www->returnInfo($nestnuol_q);			
			$nuolaida = $nuol['nuolaida'];
			
			$nestnuolpvm_q = str_replace("<dok_nr>", addslashes_mssql($dok_nr), $nestnuolpvm_q);
			$nuolpvm = $db_www->returnInfo($nestnuolpvm_q);	
			$nuolaidos_pvm = $nuolpvm['nuolpvm'];
			$nuolaida_be_pvm = $nuolaida - $nuolaidos_pvm;
			
			$zodziais = toLit(sprintf("%01.2f",$visosupvm-$nuolaida-$nuolaidos_pvm));
			if (isset($_REQUEST["cred"]) && $_REQUEST["cred"] == "1") {
				$zodziais = "-".$zodziais;
			}
			$pvmtxt = "";
			$pvmsumtxt = "";
			if ($skipedsum != "0"){
				$pvmtxt = "Kelių vinjetės<br>";
				$pvmsumtxt = sprintf("%01.2f",$skipedsum*$zenklas)."<br>";
			}
			if ($pvm_5 > 0) {
				$pvmtxt .= "<br>PVM 5%";
				$pvmsumtxt .= "<br>" . sprintf("%01.2f",$pvm_5*$zenklas) ;
			} 
			if ($pvm_9 > 0) {
				$pvmtxt .= "<br>PVM 9%";
				$pvmsumtxt .=  "<br>" .sprintf("%01.2f",$pvm_9*$zenklas) ;
			} 
			if ($pvm_18 > 0) {
				$pvmtxt .= "<br>PVM 18%";
				$pvmsumtxt .=  "<br>" .sprintf("%01.2f",$pvm_18*$zenklas) ;
			} 
			if ($pvm_19 > 0) {
				$pvmtxt .= "<br>PVM 19%";
				$pvmsumtxt .=  "<br>" .sprintf("%01.2f",$pvm_19*$zenklas) ;
			} 
			if ($pvm_21 > 0) {
				$pvmtxt .= "<br>PVM 21%";
				$pvmsumtxt .=  "<br>" .sprintf("%01.2f",($pvm_21-$nuolaidos_pvm)*$zenklas) ;
			}
			
		if (isset($_REQUEST["type"]) && $_REQUEST["type"] == "p") {	
			$colspan = 2;
		} else {
			$colspan = 0;
		}
		if ($nuolaida != 0) {
			$html .= "<tr><td colspan=\"" . (4+$colspan) ."\"><font size=\"-1\"></font></td><td align=\"right\"><font size=\"-1\">Nuolaida pagal sutartį</font></td><td></td><td align=\"right\" ><font size=\"-1\">".sprintf("%01.2f",$nuolaida*(-1)*$zenklas)."</font></td></tr>";
		}
			$html .= "<tr><td colspan=\"" . (4+$colspan) ."\"><font size=\"-1\">Suma žodžiais</font></td><td align=\"right\"><font size=\"-1\">Viso be PVM</font></td><td></td><td align=\"right\" ><font size=\"-1\">".sprintf("%01.2f",($visobepvm-$nuolaida)*$zenklas)."</font></td></tr>";
			$html .= "<tr><td colspan=\"" . (7+$colspan) ."\"><font size=\"-1\">". trim($zodziais) ."</font></td></tr>";	
			$html .= "<tr><td colspan=\"" . (7+$colspan) ."\"></td></tr>";
			$html .= "<tr><td colspan=\"" . (7+$colspan) ."\"></td></tr>";
			$html .= "<tr><td colspan=\"" . (2+$colspan) ."\"><font size=\"-1\">".$isr."</font></td><td rowspan=\"2\" colspan=\"2\"></td>
			<td align=\"right\"><font size=\"-1\">".$pvmtxt."</font></td>
			<td></td><td align=\"right\"><font size=\"-1\">".$pvmsumtxt."</font></td></tr>";
			$html .= "<tr><td colspan=\"" . (5+$colspan) ."\"></td></tr>";
			$html .= "<tr><td colspan=\"" . (3+$colspan) ."\"><font size=\"-1\">". $par . " " .$man."</font></td><td align=\"right\" colspan=\"2\" style=\"border-top:1px solid #000000;\"><font size=\"-1\">Suma apmokėjimui</font></td><td colspan=\"2\" style=\"border-top:1px solid #000000;\" align=\"right\"><font size=\"-1\">".sprintf("%01.2f",($visosupvm-$nuolaida-$nuolaidos_pvm)*$zenklas)."</font></td></tr>";
			$html .= "<tr><td colspan=\"" . (7+$colspan) ."\"><img height=\"60\" src=\"parasai/".$img."\"/></td></tr>";	
			$html .= "</table><br><br>

	
	<font size=\"+2\">Dėkojame, kad naudojatės mūsų paslaugomis!</font><br><font size=\"-2\">
	". $tekstas . "</font>";

?>